﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using KLY.DataModels;
using KLY.Tools;

namespace KLY.ServiceCore
{
    public class GerVerifyCode : ServiceBase<SendMessageRequest, SendMessageResponse>
    {
        public GerVerifyCode(SendMessageRequest request)
        {
            this._request = request;
        }

        public override SendMessageResponse Process()
        {
            if (!Validate())
            {
                return new SendMessageResponse
                {
                    Message = "手机号码异常。",
                    Ok = false
                };
            }

            base.Url = string.Format("http://{0}/v1/api/101006/", BizCommon.Domain);
            base.Method = HttpMethod.POST;
            base.ListHead = new List<RequestHead>
                {
                    new RequestHead
                    {
                        HeaderName="version",
                        HeaderValue="1.0.0"
                    }
                };
            base.Request = this._request;
            return base.Process();
        }

        private bool Validate()
        {
            return BizCommon.CheckIsValidateMobilePhone(this._request.Phone);
        }
        private SendMessageRequest _request;
    }
}
